package hu.sulirend.model;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

/**
 * A SubjectOfTeacher determines the Subject and a Teacher for some members of the Clazz
 * which determined by Students. They can have Lessons of this Subject.
 *
 * @see <code>hu.sulirend.model.SubjectOfTeacher</code>
 * @see <code>hu.sulirend.model.Students</code>
 * @see <code>hu.sulirend.model.Lesson</code>
 *
 * @author <a href="mailto: peter.szilagyi@gmail.com">Peter Szilagyi</a> 
 * @since 2008
 */
@Entity
public class StudentGroup extends BaseEntity {

	private static final long serialVersionUID = 3596486617364824401L;
	
	private SubjectOfTeacher subject;
	private Membership students;
	private Set<Lesson> lessons;
	
	private ClazzGroups clazzGroups;
	private CombinedGroups combinedGroups;
	
	@ManyToOne(optional=false, fetch=FetchType.EAGER, cascade={})
	@JoinColumn(name="SUBJECTOFTEACHER_ID", referencedColumnName="id", unique=false, nullable=false, updatable=true, insertable=true)
	public SubjectOfTeacher getSubject() {
		return subject;
	}
	public void setSubject(SubjectOfTeacher subject) {
		this.subject = subject;
	}
	@ManyToOne(optional=false, fetch=FetchType.LAZY, cascade={})
	@JoinColumn(name="MEMBERSHIP_ID", referencedColumnName="id", unique=false, nullable=false, updatable=true, insertable=true)
	public Membership getStudents() {
		return students;
	}
	public void setStudents(Membership students) {
		this.students = students;
	}
	@OneToMany(fetch=FetchType.EAGER, cascade={CascadeType.REMOVE}, mappedBy="studentGroup")
	public Set<Lesson> getLessons() {
		return lessons;
	}
	public void setLessons(Set<Lesson> lessons) {
		this.lessons = lessons;
	}
	@ManyToOne(optional=false, fetch=FetchType.LAZY, cascade={})
	@JoinColumn(name="CLAZZGROUPS_ID", referencedColumnName="id", unique=false, nullable=false, updatable=true, insertable=true)
	public ClazzGroups getClazzGroups() {
		return clazzGroups;
	}
	public void setClazzGroups(ClazzGroups clazzGroups) {
		this.clazzGroups = clazzGroups;
	}
	@ManyToOne(optional=true, fetch=FetchType.LAZY, cascade={})
	@JoinColumn(name="COMBINEDGROUPS_ID", referencedColumnName="id", unique=false, nullable=true, updatable=true, insertable=true)
	public CombinedGroups getCombinedGroups() {
		return combinedGroups;
	}
	public void setCombinedGroups(CombinedGroups combinedGroups) {
		this.combinedGroups = combinedGroups;
	}
	
}
